import apiSlice from "@/store/request/apiSlice";
const { useMusicGetMusicInfoQuery,useLazyMusicGetMusicInfoQuery } = apiSlice;
function ApiUse() {
  let result = null;
  const { data, isLoading, isSuccess, refetch } = useMusicGetMusicInfoQuery();
  const [trigger,{data:lazyData}] = useLazyMusicGetMusicInfoQuery();
  console.log(data);
  const refesh = () => {
    refetch(); //重新请求
  };
  const lazyRefesh = () => {
    trigger()//手动触发
  };

  
  if (isLoading) {
    return <div>loading</div>;
  }
  if (isSuccess) {
    return (
      <div>
        <Button type="primary" onClick={refesh}>
          重新发送请求
        </Button>
        <Button type="primary" onClick={lazyRefesh}>
          懒加载重新发送请求
        </Button>
        <div>useMusicGetMusicInfoQuery:{JSON.stringify(data)}</div>
        <div>useLazyMusicGetMusicInfoQuery:{JSON.stringify(lazyData)}</div>
      </div>
    );
  }
}
export default ApiUse;
